home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / gsdbloo.exe / DEMOB005.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-24  |  2KB  |  79 lines

  1. program DemoB005;
  2. {------------------------------------------------------------------------------
  3.                               DBase File Lister
  4.                                    Sample 5
  5.                                  Demo Program
  6.  
  7.        Copyright (c)  Richard F. Griffin
  8.  
  9.        10 February 1992
  10.  
  11.        102 Molded Stone Pl
  12.        Warner Robins, GA  31088
  13.  
  14.        -------------------------------------------------------------
  15.        This program demonstrates how dBase files may be appended using
  16.        Griffin Solutions units.
  17.  
  18.        If the DEMOB1.DBF file does not exist, the program will display a
  19.        a message that the file was not found and to run DEMOB001 to make
  20.        the file.
  21.  
  22.        The program initializes a dBase file object, opens the file, appends
  23.        a record, and proceeds to list selected fields from each record.
  24.  
  25. -------------------------------------------------------------------------------}
  26.  
  27. uses
  28.    CRT,
  29.    DOS,
  30.    GS_Date,
  31.    GS_dBase,
  32.    GS_DBFld,
  33.    GS_FileH,
  34.    GS_Strng;
  35.  
  36. const
  37.    s1 = 'The Last';
  38.  
  39. var
  40.    MyFile  : GS_dBFld_Objt;
  41.    ftest   : file;
  42.    s2      : string[8];
  43. begin
  44.    ClrScr;
  45.    if not GS_FileExists(ftest, 'DEMOB1.DBF') then
  46.    begin
  47.       writeln('File DEMOB1.DBF not found.  Run DEMOB001 to create.');
  48.       halt;
  49.    end;
  50.                        {The 'Real' example starts here}
  51.  
  52.    MyFile.Init('DEMOB1');          {Initialize object using the dBase III}
  53.                                   {file DEMOB1.  DBF Extension assumed}
  54.    MyFile.Open;                   {Open the object's file}
  55.  
  56.                  {Insert a record}
  57.  
  58.    MyFile.Blank;
  59.    MyFile.StringPut('LASTNAME',s1);
  60.    s2 := Unique_Field;
  61.    MyFile.StringPut('FIRSTNAME',s2);
  62.    MyFile.DatePut('BIRTHDATE',GS_Date_Curr);
  63.    MyFile.Append;
  64.  
  65.                  {Now read the records}
  66.  
  67.    MyFile.GetRec(Top_Record);     {Get the first record in the file}
  68.    while not MyFile.File_EOF do   {Repeat until end-of-file}
  69.    begin
  70.       writeln(MyFile.FieldGet('LASTNAME'),' ',
  71.               MyFile.FieldGet('FIRSTNAME'),'  ',
  72.               MyFile.FieldGet('BIRTHDATE'));
  73.       MyFile.GetRec(Next_Record); {Get the next sequential record}
  74.    end;
  75.    MyFile.Close;
  76.    write('Press any Key to continue:');
  77.    repeat until KeyPressed;
  78. end.
  79.